<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="css/pintuer.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery.js"></script>
<script src="js/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>增加内容</strong></div>
  <div class="body-content">
    <form method="post"  id="form-x" class="form-x" action="/workview/superviseadd1">

      <div class="form-group">
        <div class="label">
          <label>选择课程id：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="course_id" id="course_id" data-validate="required:选择课程id" />
          <span style="margin-left: 10px; color: red;">*</span>
          <div class="tips"> </div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>老师工号：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="tno" id="tno" data-validate="required:请输入添加老师工号" />
          <span style="margin-left: 10px; color: red;">*</span>
          <div class="tips"> </div>
        </div>
      </div>
	  
	  <div class="form-group">
	    <div class="label">
	      <label>添加学院：</label>
	    </div>
		  <div class="field">
			  <select name="college_name" id="college_name" class="input w50">
				  <option selected="selected">请选择分类</option>
				  <option value="软件学院">软件学院</option>
				  <option value="人文学院">人文学院</option>
			  </select>
			  <span style="margin-left: 10px; color: red;">*</span>
			  <div class="tips"></div>
		  </div>
	  </div>

	  <div class="form-group">
		   <div class="label">
		     <label>限选年级：</label>
		   </div>
		   <div class="field">
		     <input type="text" class="input w50" value="17" name="restricted_grade" id="restricted_grade" data-validate="required:请输入限选年级"/>
			   <span style="margin-left: 10px; color: red;">*</span>
		     <div class="tips"> </div>
		   </div>
	   </div>

		<div class="form-group">
			<div class="label">
				<label>输入时间：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="8：00" name="time" id="time" data-validate="required:请输入时间"/>
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

	 <div class="form-group">
	   <div class="label">
	     <label>小节：</label>
	   </div>
	   <div class="field">
	     <input type="text" class="input w50" value="2" name="know" id="know" data-validate="required:请输入时间" />
		   <span style="margin-left: 10px; color: red;">*</span>
	     <div class="tips"> </div>
	   </div>
	 </div>

		<div class="form-group">
			<div class="label">
				<label>地点：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="次教208" name="place" id="place" data-validate="required:请输入地点" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>最大人数：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="60" name="max_number" id="max_number" data-validate="required:当前人数默认为60" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>最小人数：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="30" name="min_number" id="min_number" data-validate="required:当前人数默认为30" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>当前人数默认为0：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="1" name="current_number" id="current_number" data-validate="required:当前人数默认为0" />
				<span style="margin-left: 10px; color: red;">*</span>
				<div class="tips"> </div>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label>备注：</label>
			</div>
			<div class="field">
				<input type="text" class="input w50" value="" name="remark" id="remark" data-validate="required:备注" />
				<div class="tips"> </div>
			</div>
		</div>
   
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="button" id="button bg-main icon-check-square-o" onclick="check1()"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>

<script src="js/jquery.min.js"></script>
<script type="text/javascript">
	    function check1(){
            var  course_id=document.getElementById("course_id").value;
            var  tno=document.getElementById("tno").value;
            var  college_name=document.getElementById("college_name").value;
            var  restricted_grade=document.getElementById("restricted_grade").value;
            var  time=document.getElementById("time").value;
            var  know=document.getElementById("know").value;
            var  place=document.getElementById("place").value;
            var  max_number=document.getElementById("max_number").value;
            var  min_number=document.getElementById("min_number").value;
            var  current_number=document.getElementById("current_number").value;
            var  remark=document.getElementById("remark").value;
	    $.ajax({
            type:"POST",
            dataType:"json",
            url:"/workview/elcouradd",
	        data: ({
                course_id: course_id,
                tno: tno,
                college_name: college_name,
                restricted_grade: restricted_grade,
                time: time,
                know: know,
                place: place,
                max_number: max_number,
                min_number: min_number,
                current_number: current_number,
                remark: remark
            }),
	        success:function(data){
	                console.log(data);
	                if(data.status==401){
	                    alert("熔断开启，系统异常");
	                    window.location.href="login.html";
	                    return;
	                }
	                if(data.status==200) {
	                    localStorage.setItem("supervise",data.data);
	                    window.location.href="elective_courselist.html";
	                    return;
	                }
	                if(data.status==500) {
	                    alert("添加失败");
	                    window.location.href="elective_courselist.html";
	                    return;
	                }
	                 if(data.status==null) {
	                    alert("添加异常");
	                    window.location.href="elective_courselist.html";
	                    return;
	                 }
	        },
	        error:function(XMLHttpRequest,textStatus) {
	            if (textStatus === 'timeout') {
	                alert('請求超時');
	                setTimeout(function () {
	                    alert('重新请求');
	                }, 2000);
	            }
	           // window.location.href="login.html";
                alert("系统异常ajax失败");
                window.location.href="elective_courselist.html";
	        }
	
	    });
	
	}
	
	
</script>
</body>
</html>